package com.heliang.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DataUtil {
	/**
	 * @param dataString 当前时间以前的时间
	 * @return int 传入的时间到现在过了几天
	 */
	public static int dateDiff(long dataString) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");
		String startTime = sdf.format(new Date(dataString*1000));
		String endTime = sdf.format(new Date());
		String format = "yyyy-MM-dd hh:mm";
		SimpleDateFormat sd = new SimpleDateFormat(format);
		long nd = 1000*24*60*60;//一天的毫秒数
		long diff = 0;
		try {
			diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		long day = diff/nd;//计算差多少天
		return (int)day;
	}
}
